<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
  xmlns:a="&a;"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:o="&a;AgentProfile#view"
  exclude-result-prefixes="xsl a l o"
>
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;AgentProfile#view')"/>
  <xsl:variable name="o:actions-l10n" select="$o:l10n/l:context[@name='actions']/*"/>
  
  <xsl:template match="a:keywords" mode="a:main-meta"/>
  
  <!-- xsl:template match="a:acl[@action='update-account' or @action='update-depiction' or @action='show-depiction']" mode="a:node-action">  
    <xsl:param name="action"/> 
    <xsl:param name="key" select="@action"/>
    <xsl:call-template name="a:node-action">
      <xsl:with-param name="action" select="$action"/>
      <xsl:with-param name="label" select="$o:actions-l10n[@key=$key]"/>
    </xsl:call-template>
  </xsl:template -->
  
  <xsl:template match="a:acl" mode="a:node-action">
    <xsl:param name="action" select="$a:action"/>
    <xsl:param name="key" select="string(@action)"/>
    <xsl:param name="label" select="$o:actions-l10n[@key=$key]"/>  
    <xsl:choose>
      <xsl:when test="$label">
        <xsl:call-template name="a:node-action">
          <xsl:with-param name="action" select="$action"/>
          <xsl:with-param name="key" select="$key"/>
          <xsl:with-param name="label" select="$label"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>  
  
  <xsl:template match="a:acl[@action='search-memberships']" mode="a:node-action">  
    <xsl:param name="action" select="$a:action"/>
    <xsl:param name="key" select="string(@action)"/> 
    <xsl:call-template name="a:node-action-href-ext">
      <xsl:with-param name="action" select="$action"/>
      <xsl:with-param name="label" select="$o:actions-l10n[@key=$key]"/>
      <xsl:with-param name="href-ext" select="'search=show-all&amp;event=show-all'"/>
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="a:acl[@action='show-depiction']" mode="a:node-action">  
    <xsl:param name="action" select="$a:action"/>
    <xsl:param name="key" select="string(@action)"/> 
    <xsl:call-template name="a:node-action-href-ext">
      <xsl:with-param name="action" select="$action"/>
      <xsl:with-param name="label" select="$o:actions-l10n[@key=$key]"/>
      <xsl:with-param name="href-ext" select="concat('modified=',/*/a:content/a:grouping[@key='account-details']/a:image[@role='depiction']/@modified)"/>
    </xsl:call-template>
  </xsl:template>
  
  
  <xsl:template match="a:grouping[@key='account-details']">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>
    <div class="agent-info">
      <xsl:apply-templates>
        <xsl:with-param name="l10n" select="$l10n"/>
      </xsl:apply-templates>
      <div class="spacer"/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:image">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>
    <xsl:if test="@uri">
      <div class="{@role}">
        <img src="{concat(a:format-node-action('show-depiction'),'&amp;modified=',@modified)}" alt='{$l10n[@key="no-depiction"]}'/>             
        <div class="spacer"/>
      </div>    
    </xsl:if>    
  </xsl:template>
  
  <xsl:template match="a:dict[@key='agent']">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>
    <div class='dict account'>
      <xsl:apply-templates mode="a:agent-dict">
        <xsl:with-param name="l10n" select="$l10n"/>
      </xsl:apply-templates>
      <div class="spacer"/>
    </div>
  </xsl:template>  
  
  <xsl:template match="a:entry[@key='depiction']" mode="a:agent-dict"/>
  
  <xsl:template match="a:entry[@key='nick']" mode="a:agent-dict" name="o:nick-entry">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>    
    <div class='entry nick'>
      <div class='key'>
        <span><xsl:value-of select="$l10n[@key='nick']"/></span>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <span>
          <xsl:value-of select="."/>
        </span>
        <div class="spacer"/>
      </div>
      <div class="spacer"/>
    </div> 
  </xsl:template>
  
  <xsl:template match="a:entry[@key='name']" mode="a:agent-dict" name="o:name-entry">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>    
    <div class='entry name'>
      <div class='key'>
        <span><xsl:value-of select="$l10n[@key='name']"/></span>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <span>
          <xsl:value-of select="."/>
        </span>
        <div class="spacer"/>
      </div>
      <div class="spacer"/>
    </div> 
  </xsl:template>
  
  <xsl:template match="a:entry[@key='homepage']" mode="a:agent-dict" name="o:homepage-entry">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>    
    <div class='entry homepage'>
      <div class='key'>
        <span><xsl:value-of select="$l10n[@key='homepage']"/></span>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <a href='{.}'>
          <xsl:value-of select="substring(.,8)"/>
        </a>
        <div class="spacer"/>
      </div>
      <div class="spacer"/>
    </div> 
  </xsl:template>
  
  <xsl:template match="a:entry[@key='mbox']" mode="a:agent-dict" name="o:mbox-entry">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='account']/*"/>    
    <div class='entry mbox'>
      <div class='key'>
        <div><xsl:value-of select="$l10n[@key='mbox']"/></div>
        <div class="spacer"/>
      </div>
      <div class='value'>
        <a href='{.}'>
          <xsl:value-of select="substring(.,8)"/>
        </a>
        <div class="spacer"/>
      </div>
      <div class="spacer"/>
    </div> 
  </xsl:template>  
  
</xsl:stylesheet>

